'use strict';
angular.module('clientApp')
.value('hotelURL', 'http://127.0.0.1:8080/M2TIIL_AERO_2015')
.factory('hotelAPI', function($http, hotelURL) {
    return {
        add : function(hotel) {
            return $http({
                url : hotelURL + '/enregistrerHotel.htm?name=' + hotel.name + '&address=' + hotel.address + '&classification=' + hotel.classification,
                method : 'POST',
                headers : {
                    'Content-Type' : 'application/json'
                }
            });
        },
        modify : function(hotel) {
        	return $http({
	        	url : hotelURL + '/modifiyHotel.htm?idxHotel=' + hotel.id + '&name=' + hotel.name + '&address=' + hotel.address + '&classification=' + hotel.classification,
	        	method : 'GET',
	        	headers : {
	        		'Content-Type' : 'application/json'
	        	}
        	});
        },
        get : function(id) {
            return $http({
                url : hotelURL + '/getHotel.htm?idxHotel=' + id,
                method : 'GET',
                headers : {
                    'Content-Type' : 'application/json'
                }
            });
        },
        list : function(){
        	return $http({
        		url : hotelURL + '/getHotels.htm',
        		method : 'GET',
        		headers : {
        			'Content-Type' : 'application/json'
        		}
        	});
        },
        remove : function(id) {
        	return $http({
        		url : hotelURL + '/suppHotel.htm?idHotel=' + id,
        		method : 'GET',
        		headers : {
        			'Content-Type' : 'application/json'
        		}
        	});
        }
    };
});